package k.order.controller;

import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
public class OrderController {
    @GetMapping("order")
    public String getOrder(HttpServletRequest request) {
        return "order"+request.getServerPort();
    }

    /// //////////////////////////////
    @RabbitListener(queuesToDeclare = @Queue("workQueue")) // queuesToDeclare 自动声明队列
    public void rev1(String message) throws InterruptedException {
        Thread.sleep(200);
        System.out.println("message200 = " + message);
    }
    @RabbitListener(queuesToDeclare = @Queue("workQueue")) // queuesToDeclare 自动声明队列
    public void rev2(String message) throws InterruptedException {
        Thread.sleep(400);
        System.out.println("message400 = " + message);
    }
}
